//
//  WinRecordViewCell.m
//  MoXiProject
//
//  Created by 周筱雯 on 2017/7/3.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "WinRecordViewCell.h"
#import "WinRecordModel.h"
#import "BuyLotteryModel.h"
#import "CollcetionModel.h"

@interface WinRecordViewCell()
@property (weak, nonatomic) IBOutlet UILabel *userNumber;
@property (weak, nonatomic) IBOutlet UILabel *userType;
@property (weak, nonatomic) IBOutlet UILabel *userDate;

@property (nonatomic,strong) UILabel * annNumer;
@property (nonatomic,strong) UILabel * fernumber;

@end


@implementation WinRecordViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void) collDataSource:(CollcetionModel *) model{
    
    [self.userType setText:model.collLotteryTypeName];
    [self.userDate setText:[MXUtility getTimeWithTimestamp:model.collcreateTime WithDateFormat:@"yyyy-MM-dd"]];
    
    NSString *string = model.collnumberlf;
    NSArray *aArray = [string componentsSeparatedByString:@","];
    
    for (int i=0; i<aArray.count; i++) {
        if (IPHONE5) {
            self.annNumer = [[UILabel alloc]initWithFrame:CGRectMake(15+25*i, 22, 20, 20)];
        }else{
            self.annNumer = [[UILabel alloc]initWithFrame:CGRectMake(15+35*i, 22, 30, 30)];
        }
        [self.annNumer setTextAlignment:NSTextAlignmentCenter];
        self.annNumer.textColor = [UIColor whiteColor];
        self.annNumer.text = [NSString stringWithFormat:@"%d",[aArray[i] intValue]];
        self.annNumer.layer.cornerRadius = self.annNumer.width / 2;
        self.annNumer.layer.masksToBounds =  YES;
        [self.annNumer setFont:[UIFont systemFontOfSize:12.f]];
        [self.annNumer setBackgroundColor:DEF_COLOR_MAINCOLOR_LOTTERY];
        [self addSubview:self.annNumer];
    }
    
    
    
    /**
     参考号
     */
    NSString * fernumber = model.collnumberrt;
    NSArray *fArray = [fernumber componentsSeparatedByString:@","];
    
    for (int i=0; i<fArray.count; i++) {
        
        if (IPHONE5) {
            self.fernumber = [[UILabel alloc]initWithFrame:CGRectMake((self.annNumer.x + self.annNumer.width + 10)+25*i, 22, 20, 20)];
            
        }else{
            self.fernumber = [[UILabel alloc]initWithFrame:CGRectMake((self.annNumer.x + self.annNumer.width + 10)+35*i, 22, 30, 30)];
        }        [self.fernumber setTextAlignment:NSTextAlignmentCenter];
        self.fernumber.textColor = [UIColor whiteColor];
        [self.fernumber setFont:[UIFont systemFontOfSize:12.f]];
        self.fernumber.text = [NSString stringWithFormat:@"%d",[fArray[i] intValue]];
        self.fernumber.layer.cornerRadius = self.fernumber.width / 2;
        self.fernumber.layer.masksToBounds =  YES;
        [self addSubview:self.fernumber];
        [self.fernumber setBackgroundColor:DEF_COLOR_0080FF];
    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
